
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Task;
import cn.edu.scau.cmi.hombio.domain.TaskStatusType;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class TaskStatusTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TaskStatusTypeService service;

	/**
	 * Instantiates a new TaskStatusTypeServiceTest.
	 *
	 */
	public TaskStatusTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTaskStatusTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTaskStatusTypeByPrimaryKey 
		Integer id = 0;
		TaskStatusType response = null;
		response = service.findTaskStatusTypeByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findTaskStatusTypeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Return all TaskStatusType entity
	* 
	 */
	@Test
	public void findAllTaskStatusTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllTaskStatusTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TaskStatusType> response = null;
		response = service.findAllTaskStatusTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTaskStatusTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing TaskStatusType entity
	* 
	 */
	@Test
	public void deleteTaskStatusType() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskStatusType 
		TaskStatusType taskstatustype = new cn.edu.scau.cmi.hombio.domain.TaskStatusType();
		service.deleteTaskStatusType(taskstatustype);
	}

	/**
	 * Operation Unit Test
	* Return a count of all TaskStatusType entity
	* 
	 */
	@Test
	public void countTaskStatusTypes() {
		Integer response = null;
		response = service.countTaskStatusTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countTaskStatusTypes
	}

	/**
	 * Operation Unit Test
	* Save an existing TaskStatusType entity
	* 
	 */
	@Test
	public void saveTaskStatusType() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskStatusType 
		TaskStatusType taskstatustype_1 = new cn.edu.scau.cmi.hombio.domain.TaskStatusType();
		service.saveTaskStatusType(taskstatustype_1);
	}

	/**
	 * Operation Unit Test
	* Load an existing TaskStatusType entity
	* 
	 */
	@Test
	public void loadTaskStatusTypes() {
		Set<TaskStatusType> response = null;
		response = service.loadTaskStatusTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTaskStatusTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing Task entity
	* 
	 */
	@Test
	public void deleteTaskStatusTypeTasks() {
		// TODO: JUnit - Populate test inputs for operation: deleteTaskStatusTypeTasks 
		Integer taskstatustype_id = 0;
		Integer related_tasks_id = 0;
		TaskStatusType response = null;
		response = service.deleteTaskStatusTypeTasks(taskstatustype_id, related_tasks_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTaskStatusTypeTasks
	}

	/**
	 * Operation Unit Test
	* Save an existing Task entity
	* 
	 */
	@Test
	public void saveTaskStatusTypeTasks() {
		// TODO: JUnit - Populate test inputs for operation: saveTaskStatusTypeTasks 
		Integer id_1 = 0;
		Task related_tasks = new cn.edu.scau.cmi.hombio.domain.Task();
		TaskStatusType response = null;
		response = service.saveTaskStatusTypeTasks(id_1, related_tasks);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTaskStatusTypeTasks
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
